package com.ruoyi.system.service.impl;

import com.ruoyi.system.domain.Area;
import com.ruoyi.system.mapper.AreaMapper;
import com.ruoyi.system.service.IAreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author:cocoKe
 * @Description:
 * @VERSON:1.8
 * @create:2025-02-27 09:30
 * @Date:2025/2/27
 */
@Service
public class AreaServiceImpl implements IAreaService {


    @Autowired
    private AreaMapper areaMapper;

    public List<Area> buildTree(int rootId){
        List<Area> list = areaMapper.selectAreaByPid(rootId);

        for (Area area : list) {
            // 递归
            area.setChildren(buildTree(area.getId()));
        }
        return list;
    }






}
